home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / doc / assert.doc < prev    next >
Text File  |  1993-07-05  |  2KB  |  91 lines

  1.  
  2.     ASSERT.DOC (c)Copyright 1990, Matthew Dillon, All Rights Reserved
  3.  
  4. TABLE OF CONTENTS
  5.  
  6. c.lib/assert/abort
  7. c.lib/assert/assert
  8.  
  9.  
  10. assert/abort                        assert/abort
  11.  
  12.    NAME
  13.     abort    - abort a program (exit with an error)
  14.  
  15.    SYNOPSIS
  16.     void abort(void);
  17.  
  18.    FUNCTION
  19.     aborts a program with a non-zero exit code.  The default abort
  20.     routine in c.lib does the equivalent of an 'exit(20);'.
  21.  
  22.     The programmer may overide the default abort routine with his
  23.     own.
  24.  
  25.    EXAMPLE
  26.     #include <stdio.h>
  27.     #include <stdlib.h>
  28.  
  29.     main(ac, av)
  30.     int ac;
  31.     char **av;
  32.     {
  33.         if (ac == 1) {
  34.         puts("Expected an argument!");
  35.         abort();
  36.         }
  37.         puts("Thanks!");
  38.         return(0);
  39.     }
  40.  
  41.    INPUTS
  42.     none
  43.  
  44.    RESULTS
  45.     abort() never returns
  46.  
  47.    SEE ALSO
  48.     assert
  49.  
  50.  
  51. assert/assert                        assert/assert
  52.  
  53.    NAME
  54.     assert    - assert that an expression is true, else abort
  55.  
  56.    SYNOPSIS
  57.     #include <assert.h>
  58.     assert(condition);                  /* MACRO */
  59.  
  60.    FUNCTION
  61.     assert checks the condition and if NOT true prints an error
  62.     message indicating the source filename and line number that the
  63.     assert failed at, and then abort()s.
  64.  
  65.     The DICE version of assert generates a single static string in
  66.     assert.h for each module containing the file name.  Multiple usages
  67.     of assert() refer to the same physical filename string.
  68.  
  69.    EXAMPLE
  70.     #include <assert.h>
  71.  
  72.     main(ac, av)
  73.     int ac;
  74.     char **av;
  75.     {
  76.         assert(ac > 1);         /*  expect at least one argument!   */
  77.         return(0);
  78.     }
  79.  
  80.    INPUTS
  81.     expression        - an expression which the macro converts into
  82.                   an if(!(expression)).
  83.  
  84.    RESULTS
  85.     none
  86.  
  87.    SEE ALSO
  88.     abort
  89.  
  90.  
  91.